package com.personal.service.impl;

import com.personal.dao.SupplierDao;
import com.personal.domain.Supplier;
import com.personal.service.SupplierService;
import com.personal.util.partDisplay.SupplierPart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @projectName: smartCommunity_springboot
 * @package: com.personal.service.impl
 * @className: SupplierServiceImpl
 * @author: bong~
 * @description: TODO
 * @date: 2023/8/9 16:29
 * @version: 1.0
 */


@Service
public class SupplierServiceImpl implements SupplierService {


    @Autowired
    private SupplierDao supplierDao;


    @Override
    public List<Supplier> selectAll() {
        return supplierDao.selectAll();
    }

    @Override
    public List<SupplierPart> selectPartAll() {
        return supplierDao.selectPartAll();
    }

    @Override
    public List<SupplierPart> selectPartByKey(String name, String code) {
        return supplierDao.selectPartByKey(name,code);
    }

    @Override
    public boolean add(Supplier supplier) {
        int flag= supplierDao.add(supplier);
        if(flag>0)
            return true;
        return false;
    }

    @Override
    public Supplier getUpdateData(int id) {
        return supplierDao.getUpdateData(id);
    }

    @Override
    public boolean update(Supplier supplier) {
        int flag=supplierDao.update(supplier);
        if(flag>0)
            return true;
        return false;
    }

    @Override
    public boolean delete(List<Integer> ids) {
        for(int id:ids){
            int flag=supplierDao.delete(id);
            if(flag<0){
                return false;
            }
        }
        return true;
    }
}
